﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace Vortex.IO {
	/// <summary>
	/// Resource file provider for manifest resources
	/// </summary>
	class ManifestResourceProvider : IResourceProvider {
		private Assembly _assembly;
		private string _fileName;

		/// <summary>
		/// Initializes a new instance of the <see cref="ManifestResourceProvider"/> class.
		/// </summary>
		/// <param name="resourceInfo">The manifest resource info.</param>
		public ManifestResourceProvider(Assembly assembly, string fileName) {
			_assembly = assembly;
			_fileName = fileName;
		}

		#region IResourceProvider Members

		/// <summary>
		/// Opens the reading stream for manifest resource.
		/// </summary>
		/// <returns></returns>
		public System.IO.Stream OpenStream() {
			return _assembly.GetManifestResourceStream(_fileName);
		}

		#endregion
	}
}
